<template>
  <div class="app-container">
    <el-table :data="list" style="width: 100%">
      <el-table-column prop="id" label="id" width="180"> </el-table-column>
      <el-table-column prop="developerId" label="developerId" width="180">
      </el-table-column>
      <el-table-column prop="name" label="开发者"> </el-table-column>
      <el-table-column prop="signKey" label="签名"> </el-table-column>
      <el-table-column prop="remark" label="备注"> </el-table-column>
      <el-table-column prop="status" label="状态">
        <template slot-scope="scope">
          <el-tag
            :type="scope.row.status === 0 ? 'danger' : 'success'"
            disable-transitions
          >
            {{ scope.row.status === 0 ? "禁用" : "正常" }}
          </el-tag>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="queryParams.total > 0"
      :total="queryParams.total"
      :page.sync="queryParams.page"
      :limit.sync="queryParams.pageSize"
      @pagination="getListData"
    />
  </div>
</template>

<script>
import { getDeveloperList } from "@/api/shop/index";
export default {
  name: "Index",
  data() {
    return {
      queryParams: {
        page: 0,
        pageSize: 10,
        total: 0,
      },
      formData: {
        recommendId: "",
        status: "",
        type: "",
      },
      list: [],
    };
  },
  created() {
    this.getListData({
      page: 1,
      limit: 10,
    });
  },
  methods: {
    getListData({ page, limit }) {
      getDeveloperList(
        this.queryParams,
        page || this.queryParams.page + 1,
        limit
      ).then(({ data }) => {
        this.list = data.records;
        this.queryParams.total = data.total;
        this.queryParams.page = data.current;
        this.queryParams.limit = data.size;
      });
    },
    onSearch() {
      this.queryParams = {
        ...this.queryParams,
        ...this.formData,
      };
      this.getListData({
        page: 1,
        limit: 10,
      });
    },
    reset() {
      this.formData = {
        recommendId: "",
        status: "",
        type: "",
      };
    },
  },
};
</script>

<style lang="scss" scoped>
.create {
  margin-bottom: 20px;
}
</style>
